<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <script src="https://cdn.bootcss.com/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
hello
<br/>
<a href="ajax.html" target="_blank">ajax.html</a>
<br/>
<button onclick="get00()">get00</button>
<a href="ws?fileName=jquery-3.4.1.js" target="_blank">get01-文件下载</a>
<br/>
<button onclick="post00()">post00</button>
<br>
<form action="ps" method="post" enctype="multipart/form-data" id="form">
  <div>
    <span>userName：</span>
    <input type="text" name="userName" id="userName"/>
  </div>
  <div>
    <span>password：</span>
    <input type="password" name="password" id="password"/>
  </div>
  <div>
    <input type="hidden" name="token" id="token" value="123456"/>
  </div>
  <div>
    <input type="file" name="myfile">
  </div>
  <input type="submit" value="post00-表单提交，文件上传"/>
</form>
<button onclick="post01()">post01-ajax表单提交，文件上传</button>
</body>
</html>
<script type="text/javascript">
  function get00() {
    $.ajax({
      type: "GET",
      url: "ps",
      data: {
        "id": 23423,
        "name": "xiaoming",
        "pass": "password"
      },
      success: function (data) {
        console.info(data);
      }
    })
  }

  function post00() {
    $.ajax({
      type: "POST",
      url: "ps",
      data: {
        "id": 23423,
        "name": "xiaoming",
        "pass": "password"
      },
      success: function (data) {
        console.info(data);
      }
    })
  }

  function post01() {
    var formData = new FormData();
    formData.append('name', '哈哈');
    formData.append('age', '123');
    formData.append("myfile", document.getElementsByName("myfile")[0].files[0]);
    $.ajax({
      type: "POST",
      url: 'ps',
      async: true,
      cache: false,
      processData: false,
      contentType: false,
      // data: $("#form").serialize()
      // data: new FormData($("#form")[0]),
      data: formData,
      success: function (data) {
        console.info(data);
      },
      error: function (data) {
        console.info(data);
      }
    })
  }
</script>